package hut.ai.team.screen;

import hut.ai.team.resource.ImageData;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;

public class SplashScreen extends AbstractScreen {
	private Stage stage;
	public static SplashScreen instance = null;

	public static SplashScreen getInstance() {
		if (instance == null) {
			instance = new SplashScreen();
		}
		return instance;
	}

	public SplashScreen() {
		stage = new Stage();
		stage.setViewport(480, 800, false);
		Texture bg = new Texture(Gdx.files.internal("images/bg/logo.png"));
		com.badlogic.gdx.scenes.scene2d.ui.Image iBackground = new com.badlogic.gdx.scenes.scene2d.ui.Image(bg);
		stage.addActor(iBackground);
	}

	@Override
	public void show() {
		super.show();
		ImageData.LoadImageData();
		game.manager.load("images/bg/backgrounds.atlas", TextureAtlas.class);
		game.manager.load("images/ui/ui.atlas", TextureAtlas.class);
		game.manager.load("music/a.mp3", Music.class);
		game.manager.load("music/intro.wav", Sound.class);
	}

	@Override
	public Stage getStage() {
		return stage;
	}

	@Override
	public void render(float delta) {
		super.render(delta);
		System.out.println(game.manager.getProgress());
		if (game.manager.update()) {
			System.out.println("Navigate to MenuScreen");
			game.sound.init();
			game.setScreen(MenuScreen.getInstance());
		}
	}

}
